package com.library.service.impl;


import com.library.common.core.domain.BaseEntity;
import com.library.common.core.text.Convert;
import com.library.domain.MbSignRulesGift;
import com.library.mapper.MbSignRulesGiftMapper;
import com.library.service.IMbSignRulesGiftService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 规则礼品关联 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class MbSignRulesGiftServiceImpl implements IMbSignRulesGiftService {
    @Resource
    private MbSignRulesGiftMapper mbSignRulesGiftMapper;


    /**
     * 查询规则礼品关联信息
     *
     * @param id 规则礼品关联ID
     * @return 规则礼品关联信息
     */
    @Override
    public MbSignRulesGift selectMbSignRulesGiftById(Integer id) {
        return mbSignRulesGiftMapper.selectMbSignRulesGiftById(id);
    }

    /**
     * 查询规则礼品关联列表
     *
     * @param mbSignRulesGift 规则礼品关联信息
     * @return 规则礼品关联集合
     */
    @Override
    public List<MbSignRulesGift> selectMbSignRulesGiftList(MbSignRulesGift mbSignRulesGift) {
        return mbSignRulesGiftMapper.selectMbSignRulesGiftList(mbSignRulesGift);
    }

    /**
     * 新增规则礼品关联
     *
     * @param mbSignRulesGift 规则礼品关联信息
     * @return 结果
     */
    @Override
    public int insertMbSignRulesGift(MbSignRulesGift mbSignRulesGift) {
        return mbSignRulesGiftMapper.insertMbSignRulesGift(mbSignRulesGift);
    }

    /**
     * 修改规则礼品关联
     *
     * @param mbSignRulesGift 规则礼品关联信息
     * @return 结果
     */
    @Override
    public int updateMbSignRulesGift(MbSignRulesGift mbSignRulesGift) {
        return mbSignRulesGiftMapper.updateMbSignRulesGift(mbSignRulesGift);
    }

    /**
     * 删除规则礼品关联对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMbSignRulesGiftByIds(String ids) {
        String[] strings = Convert.toStrArray(ids);
        for (String id : strings) {
            MbSignRulesGift mbSignRulesGift = mbSignRulesGiftMapper.selectMbSignRulesGiftById(Integer.valueOf(id));
            if (null == mbSignRulesGift)
                continue;
            mbSignRulesGift.setIsDelete(BaseEntity.DELETE);
            mbSignRulesGiftMapper.updateMbSignRulesGift(mbSignRulesGift);

        }
        return BaseEntity.DELETE;
    }


}
